package com.fleapx.spring.hook.springhooktest.postprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Order
@Component
public class BeanFactoryPostProcessorTest implements BeanFactoryPostProcessor {
    /**
     *容器实际实例化任何其它的bean之前读取配置元数据，并有可能修改它
     * 可以定义多个实现类，并利用order指定加载顺序
     * @param configurableListableBeanFactory
     * @throws BeansException
     */
    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
        System.out.println("进入了BeanFactoryPostProcessor实例");
        BeanDefinition bf = configurableListableBeanFactory.getBeanDefinition("user");
        System.out.println(bf.getBeanClassName());
    }
}
